<template>
	<view>
		<view class="goods-item">
			<!-- 商品左侧图片区域 -->
			<view class="goods-item-left"><image :src="goods.goods_small_logo || defaultPic" class="goods-pic"></image></view>
			<!-- 商品右侧信息区域 -->
			<view class="goods-item-right">
				<!-- 商品标题 -->
				<view class="goods-name">{{ goods.goods_name }}</view>
				<view class="goods-info-box">
					<!-- 商品价格 -->
					<view class="goods-price">￥{{ goods.goods_price | tofixed }}</view>
					<!-- ||与   |过滤器，使用过滤器进行完成 -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'my-goods',
	props: {
		goods: {
			type: Object,
			default:{},
		}
	},
	data() {
		return {
			//默认空照片
			defaultPic: 'https://bpic.588ku.com/element_pic/20/07/01/108482e327d63f5362504b005d368c14.jpg!/fw/253/quality/90/unsharp/true/compress/true'
		};
	},
	// 使用过滤器
	filters: {
		// 把数字处理为带两位小数点的数字
		tofixed(num) {
			return Number(num).toFixed(2);
		}
	},
};
</script>

<style lang="scss">
.goods-item {
	display: flex;
	padding: 20rpx 10rpx;
	border-bottom: 1rpx solid #f0f0f0;
}
.goods-item-left {
	margin-right: 10rpx;
}
.goods-pic {
	width: 200rpx;
	height: 200rpx;
	display: block;
}
.goods-item-right {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}
.goods-name {
	padding-top: 20rpx;
	margin-left: 20rpx;
	font-size: 26rpx;
}
.goods-price {
	margin-left: 20rpx;
	font-size: 36rpx;
	color: #c00000;
}
</style>
